package com.son.hotel.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.son.hotel.common.ErrorCode;
import com.son.hotel.domain.Customers;
import com.son.hotel.execption.BusinessException;
import com.son.hotel.service.CustomersService;
import com.son.hotel.mapper.CustomersMapper;
import com.son.hotel.vo.CustomAndRoomInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 孙一卓
* @description 针对表【customers(顾客)】的数据库操作Service实现
* @createDate 2025-06-24 14:49:17
*/
@Slf4j
@Service
public class CustomersServiceImpl extends ServiceImpl<CustomersMapper, Customers>
    implements CustomersService{

    @Autowired
    private CustomersMapper customersMapper;

    @Override
    public int addCustom(CustomAndRoomInfo customAndRoomInfo) {
        Customers customers = new Customers();
        customers.setName(customAndRoomInfo.getName());
        customers.setPhone(customAndRoomInfo.getPhone());
        customers.setIdentity(customAndRoomInfo.getIdentity());
        log.info("用户信息customers:{}",customers);
        int insert = customersMapper.insert(customers);
        if (insert <= 0){
            throw new BusinessException(ErrorCode.SYSTEM_ERROR,"插入失败");
        }
        return insert;
    }
}




